package listener;

import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;

public class AttributeListener implements HttpSessionAttributeListener {
    Object username = null;
    @Override
    public void attributeAdded(HttpSessionBindingEvent event) {
        username = event.getSession().getAttribute("username");
        System.out.println(username+"被加入了session域");
    }

    @Override
    public void attributeRemoved(HttpSessionBindingEvent event) {
        System.out.println(username+"被移除了session域");
    }

    @Override
    public void attributeReplaced(HttpSessionBindingEvent event) {
        HttpSessionAttributeListener.super.attributeReplaced(event);
    }
}
